/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */
#include "StockShareDialog.h"
#include "StockDatabase.h"
#include "Utilities.h"

namespace QSThink
{
	StockShareDialog::StockShareDialog(QWidget *parent)
		: QDialog(parent),_ui(new Ui::StockShareTableUI)
	{
		_ui->setupUi(this);
	}

	StockShareDialog::~StockShareDialog()
	{
		delete _ui;
	}

	void StockShareDialog::load( QString symbol )
	{
		_ui->tableWidget->clear();

		QString title=symbol;
		this->setWindowTitle(title);

		StockShareInfo* info=StockDatabase::getSingleton().getStockShareInfo(symbol);

		int cnt=info->changeCount();

		_ui->tableWidget->setRowCount(cnt);

		for (int i=0;i<cnt;++i){
			StockShareChangeItem* item=info->getChangeItem(i);
			QTableWidgetItem* item0=new QTableWidgetItem(Utilities::getDateStrByDay(item->changeDay));
			QTableWidgetItem* item1=new QTableWidgetItem(Utilities::getDateStrByDay(item->publicDay));
			QTableWidgetItem* item2=new QTableWidgetItem(Utilities::getChangeReason(item->changeReason));
			QTableWidgetItem* item3=new QTableWidgetItem(QString::number(item->totalVolume));
			QTableWidgetItem* item4=new QTableWidgetItem(QString::number(item->currentVolume));



			_ui->tableWidget->setItem(i,0,item0);
			_ui->tableWidget->setItem(i,1,item1);
			_ui->tableWidget->setItem(i,2,item2);
			_ui->tableWidget->setItem(i,3,item3);
			_ui->tableWidget->setItem(i,4,item4);


		}

		

	}

}
